package my.test.tactics.extend;

import java.util.Arrays;

/**
 * @Author 许玉康
 * @Date 2019/8/29 8:41
 */
public class Client {

    private final static String ADD_SYMBOL = "+";
    private final static String SUB_SYMBOL = "-";
    public static void main(String[] args) {
        int a = Integer.parseInt(args[0]);
        String symbol = args[1];
        int b = Integer.parseInt(args[2]);
        System.out.println("输入的参数为:" + Arrays.toString(args));

        //上下文
        Context context = null;
        //判断初始化哪一个策略
        if(symbol.equals(ADD_SYMBOL)) {
            context = new Context(new Add());
        } else if(symbol.equals(SUB_SYMBOL)) {
            context = new Context(new Sub());
        }
        System.out.println("运行结果为:" + context.exec(a, b, symbol));
    }
}
